package com.qd.common.panda.domain.entity.carpark;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.cdqidi.util.page.BaseQuery;
import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.DeleteGroup;
import com.cdqidi.valid.group.UpdateGroup;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

/**
 * 停车场信息
 *
 * @author sjk
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
@ToString
public class CarParkDTO extends BaseQuery {

    @ExcelIgnore
    @JsonIgnore
    private static final String EXCEL_TITLE = "停车场信息";
    /**
     * 主键
     */
    @ExcelProperty(value = {EXCEL_TITLE, "停车场标识"})
    @Size(max = 50, message = "停车场标识长度不能超过{max}位", groups = {DeleteGroup.class, UpdateGroup.class})
    @JsonProperty("pId")
    private String pId;
    /**
     * 停车场编码:自动生成，用于葵花码中的参数
     */
    @ExcelProperty(value = {EXCEL_TITLE, "停车场编码"})
    @Size(max = 20, message = "停车场编码长度不能超过{max}位", groups = DefaultGroup.class)
    private String code;
    /**
     * 名称
     */
    @ExcelProperty(value = {EXCEL_TITLE, "名称"})
    @NotBlank(message = "名称不能为空", groups = DefaultGroup.class)
    @Size(max = 100, message = "名称长度不能超过{max}位", groups = DefaultGroup.class)
    private String name;
    /**
     * 介绍
     */
    @ExcelProperty(value = {EXCEL_TITLE, "介绍"})
    @Size(max = 200, message = "介绍长度不能超过{max}位", groups = DefaultGroup.class)
    private String introduce;
    /**
     * 总泊位
     */
    @ExcelProperty(value = {EXCEL_TITLE, "总泊位"})
    @NotNull(message = "总泊位不能为空", groups = DefaultGroup.class)
    private Integer parkNum;
    /**
     * 入场免费时长
     */
    @ExcelProperty(value = {EXCEL_TITLE, "入场免费时长"})
    private Integer intoFreeTime;
    /**
     * 缴费后免费时长
     */
    @ExcelProperty(value = {EXCEL_TITLE, "缴费后免费时长"})
    private Integer payFreeTime;
    /**
     * 小程序码
     */
    @ExcelIgnore
    private String qrCode;
    /**
     * 小程序码显示
     */
    @ExcelProperty(value = {EXCEL_TITLE, "小程序码"})
    private String qrCodeDisplay;
    /**
     * 停车场类型
     */
    @ExcelProperty(value = {EXCEL_TITLE, "停车场类型"})
    @NotNull(message = "停车场类型不能为空", groups = DefaultGroup.class)
    private String carParkType;
    /**
     * 停车场类型显示
     */
    private String carParkTypeDisplay;
    /**
     * 添加时间
     */
    @ExcelProperty(value = {EXCEL_TITLE, "添加时间"})
    private LocalDateTime addTime;
    /**
     * 更新时间
     */
    @ExcelProperty(value = {EXCEL_TITLE, "更新时间"})
    private LocalDateTime updateTime;
    /**
     * 人工确认入场
     */
    @ExcelProperty(value = {EXCEL_TITLE, "人工确认入场"})
    @NotBlank(message = "人工确认入场不能为空", groups = DefaultGroup.class)
    @Size(max = 20, message = "人工确认入场长度不能超过{max}位", groups = DefaultGroup.class)
    private String confirmIn;
    /**
     * 人工确认入场显示
     */
    private String confirmInDisplay;
    /**
     * 是否第三方计费
     */
    @ExcelProperty(value = {EXCEL_TITLE, "是否第三方计费"})
    @NotBlank(message = "是否第三方计费不能为空", groups = DefaultGroup.class)
    @Size(max = 20, message = "是否第三方计费长度不能超过{max}位", groups = DefaultGroup.class)
    private String thirdPartyBill;
    /**
     * 是否第三方计费显示
     */
    private String thirdPartyBillDisplay;
    /**
     * 人工确认出场
     */
    @ExcelProperty(value = {EXCEL_TITLE, "人工确认出场"})
    @NotBlank(message = "人工确认出场不能为空", groups = DefaultGroup.class)
    @Size(max = 20, message = "人工确认出场长度不能超过{max}位", groups = DefaultGroup.class)
    private String confirmOut;
    /**
     * 人工确认出场显示
     */
    private String confirmOutDisplay;
    /**
     * 操作人
     */
    @ExcelProperty(value = {EXCEL_TITLE, "操作人"})
    private String operator;
    /**
     * 操作人显示
     */
    private String operatorDisplay;
    /**
     * 机构ID
     */
    @ExcelProperty(value = {EXCEL_TITLE, "机构ID"})
    private String orgId;
    /**
     * 机构显示
     */
    private String orgIdDisplay;
    /**
     * 是否启用
     */
    @ExcelProperty(value = {EXCEL_TITLE, "是否启用"})
    @NotBlank(message = "是否启用不能为空", groups = DefaultGroup.class)
    @Size(max = 20, message = "是否启用长度不能超过{max}位", groups = DefaultGroup.class)
    private String enable;
    /**
     * 是否启用显示
     */
    private String enableDisplay;
    /**
     * 是否自营
     */
    @ExcelProperty(value = {EXCEL_TITLE, "是否自营"})
    @NotBlank(message = "是否自营不能为空", groups = DefaultGroup.class)
    @Size(max = 20, message = "是否自营长度不能超过{max}位", groups = DefaultGroup.class)
    private String ownBusiness;
    /**
     * 是否自营显示
     */
    private String ownBusinessDisplay;
    /**
     * 类型
     */
    @ExcelIgnore
    @NotBlank(message = "类型不能为空", groups = DefaultGroup.class)
    @Size(max = 20, message = "类型长度不能超过{max}位", groups = DefaultGroup.class)
    private String parkType;
    /**
     * 类型显示
     */
    @ExcelProperty(value = {EXCEL_TITLE, "类型"})
    private String parkTypeDisplay;
    /**
     * 是否占道停车
     */
    @NotBlank(message = "是否占道停车不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "是否占道停车长度不能超过{max}位", groups = DefaultGroup.class)
    private String onStreet;

    @ExcelProperty(value = {EXCEL_TITLE, "是否占道停车"})
    private String onStreetDisplay;
    /**
     * 车位类型
     */
    @NotBlank(message = "车位类型不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "车位类型长度不能超过{max}位", groups = DefaultGroup.class)
    private String parkSpaceType;
    /**
     * 车位类型显示
     */
    @ExcelProperty(value = {EXCEL_TITLE, "车位类型"})
    private String parkSpaceTypeDisplay;
    /**
     * 是否有预约信息
     * sf0 否 sf1 是
     */
    private String isAppointmentSet;
    /**
     * 是否ETC支付
     */
    private String etcPay;
    /**
     * 是否ETC支付显示
     */
    private String etcPayDisplay;
    /**
     * 联系电话
     */
    @Size(max = 20, message = "联系电话长度不能超过{max}位", groups = DefaultGroup.class)
    private String contactNumber;
    /**
     * 分成比例
     */
    private Double shareRatio;
    /**
     * 违约金额
     */
    private BigDecimal defaultAmount;
    /**
     * 道闸品牌
     */
    private String gateBrand;
    /**
     * 道闸品牌显示
     */
    private String gateBrandDisplay;
    /**
     * 停车场位置信息
     */
    private CarParkLocationDTO location;
    /**
     * 充电信息
     */
    private CarParkChargeDTO charge;
    /**
     * 停车场费用设置
     */
    private CarParkFeeDTO fee;
    /**
     * 停车场图片介绍
     */
    private List<CarParkImgDTO> imgList;
    /**
     * 停车场预约设置
     */
    private CarParkAppointmentSetDTO appointmentSet;
    /**
     * 停车场停车时段不能为空
     */
    private CarParkTimeDTO time;
    /**
     * 收益设置
     */
    private List<CarParkRevenueDTO> revenueList;

    @Override
    public void freeData() {
        this.pId = null;
        this.code = null;
        this.name = null;
        this.introduce = null;
        this.parkNum = null;
        this.intoFreeTime = null;
        this.payFreeTime = null;
        this.qrCode = null;
        this.qrCodeDisplay = null;
        this.carParkType = null;
        this.carParkTypeDisplay = null;
        this.addTime = null;
        this.updateTime = null;
        this.confirmIn = null;
        this.confirmInDisplay = null;
        this.thirdPartyBill = null;
        this.thirdPartyBillDisplay = null;
        this.confirmOut = null;
        this.confirmOutDisplay = null;
        this.operator = null;
        this.operatorDisplay = null;
        this.orgId = null;
        this.orgIdDisplay = null;
        this.enable = null;
        this.enableDisplay = null;
        this.ownBusiness = null;
        this.ownBusinessDisplay = null;
        this.parkType = null;
        this.parkTypeDisplay = null;
        this.onStreet = null;
        this.onStreetDisplay = null;
        this.parkSpaceType = null;
        this.parkSpaceTypeDisplay = null;
        this.isAppointmentSet = null;
        this.etcPay = null;
        this.etcPayDisplay = null;
        this.contactNumber = null;
        this.shareRatio = null;
        this.defaultAmount = null;
        this.gateBrand = null;
        this.gateBrandDisplay = null;
        Optional.ofNullable(location).ifPresent(CarParkLocationDTO::freeData);
        Optional.ofNullable(fee).ifPresent(CarParkFeeDTO::freeData);
        Optional.ofNullable(imgList).ifPresent(List::clear);
        Optional.ofNullable(appointmentSet).ifPresent(CarParkAppointmentSetDTO::freeData);
        Optional.ofNullable(time).ifPresent(CarParkTimeDTO::freeData);
        Optional.ofNullable(charge).ifPresent(CarParkChargeDTO::freeData);
        Optional.ofNullable(revenueList).ifPresent(List::clear);
        super.freeData();
    }
}
